﻿using System;
using System.Web.Mvc;
using Zinnia.Common.DTO.Imp;
using Zinnia.Lite.Untilty;
using Zinnia.Services.Business;
using Zinnia.Services.Models;

namespace Zinnia.Demo.Controllers
{
    public class HomeController : Controller
    {
        private readonly IUserService _userService;
        public HomeController(IUserService userService)
        {
            _userService = userService;
        }
        // GET: Home
        public ActionResult Index()
        {
            throw new Exception("主页异常");
        }

        public ActionResult Success()
        {
            return View();
        }
        [HttpGet]
        public ActionResult GetAjaxTest()
        {
            throw new Exception("GetAjaxTest");
        }
        [HttpPost]
        public ActionResult PostAjaxTest()
        {
            User user = new User { Age = 20, Name = "rain" };
            _userService.UserRegister(user);
            return Json(new ReponseModel { msg = "添加成功" });
        }

        public ActionResult Encrypt(string source, string miyue)
        {
            return Content(DesEncryptHelper.Instance.Encrypt(source, miyue));
        }

        public ActionResult EncryptKeyToDecryptKey(string miyue)
        {
            return Content(DesKeyResolveHelper.EncryptKeyToDecryptKey(miyue));
        }
    }
}